package org.jeecg.modules.quartz.job;

import lombok.extern.slf4j.Slf4j;
import org.jeecg.common.util.DateUtils;
import org.jeecg.modules.bill.service.MedicineLossService;
import org.jeecg.modules.stock.entity.MedicineStock;
import org.jeecg.modules.stock.service.MedicineStockService;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;

/**
 * 药品报损过期定时任务
 *
 * @Author kxb
 * @Date:   2020-04-03
 */
@Slf4j
@Component
public class MedicineLossJob implements Job {

    @Autowired
    private MedicineStockService medicineStockService;

    private static MedicineStockService medicineStockService1;


    @PostConstruct
    public void init(){
        medicineStockService1 = this.medicineStockService;  //将注入的对象交给静态对象管理
    }

    /**
     * 查询过期数据并且生成药品报损账单表
     * @param jobExecutionContext
     * @throws JobExecutionException
     */
    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        //执行药品过期定时任务
        medicineStockService1.MedicineStockLossJob();
        log.info(String.format(" 执行药品报损过期定时任务 !  时间:" + DateUtils.getTimestamp()));
    }
}
